﻿using System;
using System.Collections.Generic;
using System.Text;

namespace csharpcore7_ch3
{
    /// <summary>
    /// 通用栈,LIFO的数据结构,Push(),Pop()
    /// </summary>
    public class Stack
    {
        int position;
        object[] data = new object[10];
        public void Push(object obj) { data[position++] = obj; }
        public object Pop() { return data[--position]; }

        static void _Main(string[] args)
        {
            Stack stack = new Stack();
            stack.Push("sausage");
            string s = (string)stack.Pop(); //向下转型。
            Console.WriteLine(s); //sausage
        }
    }
}
